namespace CodeCamp.EFDAL.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class Schema_2_0_EF44Initial : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.cc_BannedTags",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.cc_Buildings",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        EventId = c.Int(nullable: false),
                        Name = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.cc_Events", t => t.EventId)
                .Index(t => t.EventId);
            
            CreateTable(
                "dbo.cc_Events",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        DisplayName = c.String(nullable: false, maxLength: 128),
                        ShortName = c.String(nullable: false, maxLength: 32),
                        DisplayDate = c.String(nullable: false, maxLength: 64),
                        DisplayLocation = c.String(nullable: false, maxLength: 128),
                        RegistrationUrl = c.String(nullable: false, maxLength: 128),
                        SessionSubmissionsOpen = c.DateTime(nullable: false),
                        SessionSubmissionsClose = c.DateTime(nullable: false),
                        EventIsPublic = c.Boolean(nullable: false),
                        DisplaySortOrder = c.Decimal(nullable: false, precision: 18, scale: 2),
                        EventStartDate = c.DateTime(nullable: false),
                        DisconnectedPresenterProfileConnectionAllowed = c.Boolean(nullable: false),
                        ScheduleIsPublic = c.Boolean(nullable: false),
                        PriorEventProfileReuseAllowed = c.Boolean(nullable: false),
                        NonPublicEventPreviewRole = c.String(maxLength: 30),
                        AgendaIsPublic = c.Boolean(nullable: false),
                        ScheduleVisibleToPresenters = c.Boolean(nullable: false),
                        SchedulePdfUrl = c.String(maxLength: 172),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.cc_CommunitySponsors",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        EventId = c.Int(nullable: false),
                        Name = c.String(nullable: false, maxLength: 128),
                        Url = c.String(nullable: false, maxLength: 1024),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.cc_Events", t => t.EventId)
                .Index(t => t.EventId);
            
            CreateTable(
                "dbo.cc_IndividualContributors",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        EventId = c.Int(nullable: false),
                        FirstName = c.String(nullable: false, maxLength: 128),
                        LastName = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.cc_Events", t => t.EventId)
                .Index(t => t.EventId);
            
            CreateTable(
                "dbo.cc_Presenters",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        EventId = c.Int(nullable: false),
                        SiteUserId = c.Int(),
                        FirstName = c.String(nullable: false, maxLength: 128),
                        LastName = c.String(nullable: false, maxLength: 128),
                        TwitterName = c.String(maxLength: 128),
                        EmailAddress = c.String(nullable: false, maxLength: 128),
                        WebsiteUrl = c.String(maxLength: 1024),
                        BlogUrl = c.String(maxLength: 1024),
                        MobilePhone = c.String(maxLength: 20),
                        ShirtSize = c.String(maxLength: 10),
                        CreatedUTC = c.DateTime(nullable: false),
                        UpdatedBy = c.String(maxLength: 128),
                        UpdatedUTC = c.DateTime(),
                        PrivateNotes = c.String(maxLength: 1024),
                        OrganizerNotes = c.String(maxLength: 1024),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.cc_Events", t => t.EventId)
                .ForeignKey("dbo.cc_SiteUsers", t => t.SiteUserId)
                .Index(t => t.EventId)
                .Index(t => t.SiteUserId);
            
            CreateTable(
                "dbo.cc_SiteUsers",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        FirstName = c.String(nullable: false, maxLength: 128),
                        LastName = c.String(nullable: false, maxLength: 128),
                        EmailAddress = c.String(nullable: false, maxLength: 128),
                        UserIdentityIssuer = c.String(nullable: false, maxLength: 256),
                        UserIdentityProvider = c.String(nullable: false, maxLength: 256),
                        UserIdentityClaimType = c.String(nullable: false, maxLength: 256),
                        UserIdentityClaim = c.String(nullable: false, maxLength: 512),
                        UserClaimEmailAddress = c.String(maxLength: 128),
                        IpAtSignup = c.String(maxLength: 50),
                        IsApproved = c.Boolean(nullable: false),
                        IsLockedOut = c.Boolean(nullable: false),
                        LastLoginUTC = c.DateTime(),
                        LastOnlineActivityUTC = c.DateTime(),
                        Version = c.Binary(nullable: false, fixedLength: true, timestamp: true, storeType: "rowversion"),
                        CreatedUTC = c.DateTime(nullable: false),
                        CreatedBy = c.String(nullable: false, maxLength: 128),
                        UpdatedUTC = c.DateTime(),
                        UpdatedBy = c.String(maxLength: 128),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.cc_SessionPresenters",
                c => new
                    {
                        PresenterId = c.Int(nullable: false),
                        SessionId = c.Int(nullable: false),
                        Event_Id = c.Int(),
                    })
                .PrimaryKey(t => new { t.PresenterId, t.SessionId })
                .ForeignKey("dbo.cc_Presenters", t => t.PresenterId)
                .ForeignKey("dbo.cc_Sessions", t => t.SessionId)
                .ForeignKey("dbo.cc_Events", t => t.Event_Id)
                .Index(t => t.PresenterId)
                .Index(t => t.SessionId)
                .Index(t => t.Event_Id);
            
            CreateTable(
                "dbo.cc_Sessions",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        EventId = c.Int(nullable: false),
                        Title = c.String(nullable: false, maxLength: 128),
                        Description = c.String(nullable: false, maxLength: 4000),
                        SessionMaterialsUrl = c.String(maxLength: 128),
                        CreatedUTC = c.DateTime(nullable: false),
                        SessionStatusId = c.Int(nullable: false),
                        DesiredRoomSize = c.String(maxLength: 10),
                        UpdatedBy = c.String(maxLength: 128),
                        UpdatedUTC = c.DateTime(),
                        PrivateNotes = c.String(maxLength: 1024),
                        OrganizerNotes = c.String(maxLength: 1024),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.cc_Events", t => t.EventId)
                .Index(t => t.EventId);
            
            CreateTable(
                "dbo.cc_ScheduledSessions",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        RoomId = c.Int(nullable: false),
                        SessionId = c.Int(nullable: false),
                        TimeslotId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.cc_Rooms", t => t.RoomId)
                .ForeignKey("dbo.cc_Sessions", t => t.SessionId)
                .ForeignKey("dbo.cc_TimeSlots", t => t.TimeslotId)
                .Index(t => t.RoomId)
                .Index(t => t.SessionId)
                .Index(t => t.TimeslotId);
            
            CreateTable(
                "dbo.cc_Rooms",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        BuildingId = c.Int(nullable: false),
                        Name = c.String(nullable: false, maxLength: 128),
                        Floor = c.Int(),
                        Capacity = c.Int(nullable: false),
                        ShowToPublic = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.cc_Buildings", t => t.BuildingId)
                .Index(t => t.BuildingId);
            
            CreateTable(
                "dbo.cc_TimeSlots",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        EventId = c.Int(nullable: false),
                        Name = c.String(nullable: false, maxLength: 128),
                        Date = c.DateTime(nullable: false),
                        StartTime = c.Time(nullable: false),
                        EndTime = c.Time(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.cc_Events", t => t.EventId)
                .Index(t => t.EventId);
            
            CreateTable(
                "dbo.cc_SessionTags",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        SessionId = c.Int(nullable: false),
                        TagId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.cc_Sessions", t => t.SessionId)
                .ForeignKey("dbo.cc_Tags", t => t.TagId)
                .Index(t => t.SessionId)
                .Index(t => t.TagId);
            
            CreateTable(
                "dbo.cc_Tags",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        EventId = c.Int(nullable: false),
                        Name = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.cc_Events", t => t.EventId)
                .Index(t => t.EventId);
            
            CreateTable(
                "dbo.cc_SpeakerRateSpeakers",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        PresenterId = c.Int(nullable: false),
                        SpeakerUrl = c.String(maxLength: 256),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.cc_Presenters", t => t.PresenterId)
                .Index(t => t.PresenterId);
            
            CreateTable(
                "dbo.cc_PresenterBiographies",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        PresenterId = c.Int(nullable: false),
                        Content = c.String(nullable: false, maxLength: 4000),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.cc_Presenters", t => t.PresenterId)
                .Index(t => t.PresenterId);
            
            CreateTable(
                "dbo.cc_SpeakerRateEvent",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        EventId = c.Int(nullable: false),
                        EventUrl = c.String(maxLength: 256),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.cc_Events", t => t.EventId)
                .Index(t => t.EventId);
            
            CreateTable(
                "dbo.cc_Sponsors",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ImageUrl = c.String(nullable: false, maxLength: 1024),
                        ImageHeight = c.Int(nullable: false),
                        ImageWidth = c.Int(nullable: false),
                        EventId = c.Int(nullable: false),
                        Name = c.String(nullable: false, maxLength: 128),
                        Url = c.String(nullable: false, maxLength: 1024),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.cc_Events", t => t.EventId)
                .Index(t => t.EventId);
            
            CreateTable(
                "dbo.cc_Tasks",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        EventId = c.Int(nullable: false),
                        Name = c.String(nullable: false, maxLength: 128),
                        Notes = c.String(maxLength: 1024),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.cc_Events", t => t.EventId)
                .Index(t => t.EventId);
            
            CreateTable(
                "dbo.cc_Tasks_TimeSlots",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        TaskId = c.Int(nullable: false),
                        TaskTimeslotId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.cc_Tasks", t => t.TaskId)
                .ForeignKey("dbo.cc_TaskTimeSlots", t => t.TaskTimeslotId)
                .Index(t => t.TaskId)
                .Index(t => t.TaskTimeslotId);
            
            CreateTable(
                "dbo.cc_TaskTimeSlots",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Date = c.DateTime(nullable: false),
                        StartTime = c.Time(nullable: false),
                        EndTime = c.Time(nullable: false),
                        VolunteersNeeded = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.aspnetRgs_log4net",
                c => new
                    {
                        LogEntryID = c.Long(nullable: false, identity: true),
                        Application = c.String(nullable: false, maxLength: 50, unicode: false),
                        LogTimeLocal = c.DateTime(nullable: false),
                        LogDbTimeUTC = c.DateTime(nullable: false),
                        Level = c.String(nullable: false, maxLength: 10),
                        Logger = c.String(nullable: false, maxLength: 60, unicode: false),
                        UserName = c.String(maxLength: 100, unicode: false),
                        RemoteIP = c.String(maxLength: 39, unicode: false),
                        MachineName = c.String(maxLength: 100, unicode: false),
                        ThreadId = c.Int(),
                        SessionId = c.String(maxLength: 80, unicode: false),
                        URL = c.String(maxLength: 512, unicode: false),
                        Message = c.String(nullable: false, maxLength: 3072, unicode: false),
                        Exception = c.String(maxLength: 2000, unicode: false),
                    })
                .PrimaryKey(t => t.LogEntryID);
            
            CreateTable(
                "dbo.cc_Roles",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        RoleName = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.cc_Roles4Events",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        RoleName = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.cc_UsersInEventRoles",
                c => new
                    {
                        Role4EventId = c.Int(nullable: false),
                        SiteUserId = c.Int(nullable: false),
                        EventId = c.Int(nullable: false),
                        CreatedUTC = c.DateTime(nullable: false),
                        CreatedBy = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => new { t.Role4EventId, t.SiteUserId })
                .ForeignKey("dbo.cc_Roles4Events", t => t.Role4EventId, cascadeDelete: true)
                .ForeignKey("dbo.cc_SiteUsers", t => t.SiteUserId, cascadeDelete: true)
                .ForeignKey("dbo.cc_Events", t => t.EventId, cascadeDelete: true)
                .Index(t => t.Role4EventId)
                .Index(t => t.SiteUserId)
                .Index(t => t.EventId);
            
            CreateTable(
                "dbo.cc_UsersInRoles",
                c => new
                    {
                        RoleId = c.Int(nullable: false),
                        SiteUserId = c.Int(nullable: false),
                        CreatedUTC = c.DateTime(nullable: false),
                        CreatedBy = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => new { t.RoleId, t.SiteUserId })
                .ForeignKey("dbo.cc_Roles", t => t.RoleId, cascadeDelete: true)
                .ForeignKey("dbo.cc_SiteUsers", t => t.SiteUserId, cascadeDelete: true)
                .Index(t => t.RoleId)
                .Index(t => t.SiteUserId);
            
            CreateTable(
                "dbo.cc_SpeakerRateTalks",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        SessionId = c.Int(nullable: false),
                        TalkUrl = c.String(maxLength: 256),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.cc_Sessions", t => t.SessionId, cascadeDelete: true)
                .Index(t => t.SessionId);
            
            CreateTable(
                "dbo.cc_SponsorImages",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ImageUrl = c.String(nullable: false, maxLength: 1024),
                        ImageHeight = c.Int(nullable: false),
                        ImageWidth = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.cc_SpeakerRateTalks", new[] { "SessionId" });
            DropIndex("dbo.cc_UsersInRoles", new[] { "SiteUserId" });
            DropIndex("dbo.cc_UsersInRoles", new[] { "RoleId" });
            DropIndex("dbo.cc_UsersInEventRoles", new[] { "EventId" });
            DropIndex("dbo.cc_UsersInEventRoles", new[] { "SiteUserId" });
            DropIndex("dbo.cc_UsersInEventRoles", new[] { "Role4EventId" });
            DropIndex("dbo.cc_Tasks_TimeSlots", new[] { "TaskTimeslotId" });
            DropIndex("dbo.cc_Tasks_TimeSlots", new[] { "TaskId" });
            DropIndex("dbo.cc_Tasks", new[] { "EventId" });
            DropIndex("dbo.cc_Sponsors", new[] { "EventId" });
            DropIndex("dbo.cc_SpeakerRateEvent", new[] { "EventId" });
            DropIndex("dbo.cc_PresenterBiographies", new[] { "PresenterId" });
            DropIndex("dbo.cc_SpeakerRateSpeakers", new[] { "PresenterId" });
            DropIndex("dbo.cc_Tags", new[] { "EventId" });
            DropIndex("dbo.cc_SessionTags", new[] { "TagId" });
            DropIndex("dbo.cc_SessionTags", new[] { "SessionId" });
            DropIndex("dbo.cc_TimeSlots", new[] { "EventId" });
            DropIndex("dbo.cc_Rooms", new[] { "BuildingId" });
            DropIndex("dbo.cc_ScheduledSessions", new[] { "TimeslotId" });
            DropIndex("dbo.cc_ScheduledSessions", new[] { "SessionId" });
            DropIndex("dbo.cc_ScheduledSessions", new[] { "RoomId" });
            DropIndex("dbo.cc_Sessions", new[] { "EventId" });
            DropIndex("dbo.cc_SessionPresenters", new[] { "Event_Id" });
            DropIndex("dbo.cc_SessionPresenters", new[] { "SessionId" });
            DropIndex("dbo.cc_SessionPresenters", new[] { "PresenterId" });
            DropIndex("dbo.cc_Presenters", new[] { "SiteUserId" });
            DropIndex("dbo.cc_Presenters", new[] { "EventId" });
            DropIndex("dbo.cc_IndividualContributors", new[] { "EventId" });
            DropIndex("dbo.cc_CommunitySponsors", new[] { "EventId" });
            DropIndex("dbo.cc_Buildings", new[] { "EventId" });
            DropForeignKey("dbo.cc_SpeakerRateTalks", "SessionId", "dbo.cc_Sessions");
            DropForeignKey("dbo.cc_UsersInRoles", "SiteUserId", "dbo.cc_SiteUsers");
            DropForeignKey("dbo.cc_UsersInRoles", "RoleId", "dbo.cc_Roles");
            DropForeignKey("dbo.cc_UsersInEventRoles", "EventId", "dbo.cc_Events");
            DropForeignKey("dbo.cc_UsersInEventRoles", "SiteUserId", "dbo.cc_SiteUsers");
            DropForeignKey("dbo.cc_UsersInEventRoles", "Role4EventId", "dbo.cc_Roles4Events");
            DropForeignKey("dbo.cc_Tasks_TimeSlots", "TaskTimeslotId", "dbo.cc_TaskTimeSlots");
            DropForeignKey("dbo.cc_Tasks_TimeSlots", "TaskId", "dbo.cc_Tasks");
            DropForeignKey("dbo.cc_Tasks", "EventId", "dbo.cc_Events");
            DropForeignKey("dbo.cc_Sponsors", "EventId", "dbo.cc_Events");
            DropForeignKey("dbo.cc_SpeakerRateEvent", "EventId", "dbo.cc_Events");
            DropForeignKey("dbo.cc_PresenterBiographies", "PresenterId", "dbo.cc_Presenters");
            DropForeignKey("dbo.cc_SpeakerRateSpeakers", "PresenterId", "dbo.cc_Presenters");
            DropForeignKey("dbo.cc_Tags", "EventId", "dbo.cc_Events");
            DropForeignKey("dbo.cc_SessionTags", "TagId", "dbo.cc_Tags");
            DropForeignKey("dbo.cc_SessionTags", "SessionId", "dbo.cc_Sessions");
            DropForeignKey("dbo.cc_TimeSlots", "EventId", "dbo.cc_Events");
            DropForeignKey("dbo.cc_Rooms", "BuildingId", "dbo.cc_Buildings");
            DropForeignKey("dbo.cc_ScheduledSessions", "TimeslotId", "dbo.cc_TimeSlots");
            DropForeignKey("dbo.cc_ScheduledSessions", "SessionId", "dbo.cc_Sessions");
            DropForeignKey("dbo.cc_ScheduledSessions", "RoomId", "dbo.cc_Rooms");
            DropForeignKey("dbo.cc_Sessions", "EventId", "dbo.cc_Events");
            DropForeignKey("dbo.cc_SessionPresenters", "Event_Id", "dbo.cc_Events");
            DropForeignKey("dbo.cc_SessionPresenters", "SessionId", "dbo.cc_Sessions");
            DropForeignKey("dbo.cc_SessionPresenters", "PresenterId", "dbo.cc_Presenters");
            DropForeignKey("dbo.cc_Presenters", "SiteUserId", "dbo.cc_SiteUsers");
            DropForeignKey("dbo.cc_Presenters", "EventId", "dbo.cc_Events");
            DropForeignKey("dbo.cc_IndividualContributors", "EventId", "dbo.cc_Events");
            DropForeignKey("dbo.cc_CommunitySponsors", "EventId", "dbo.cc_Events");
            DropForeignKey("dbo.cc_Buildings", "EventId", "dbo.cc_Events");
            DropTable("dbo.cc_SponsorImages");
            DropTable("dbo.cc_SpeakerRateTalks");
            DropTable("dbo.cc_UsersInRoles");
            DropTable("dbo.cc_UsersInEventRoles");
            DropTable("dbo.cc_Roles4Events");
            DropTable("dbo.cc_Roles");
            DropTable("dbo.aspnetRgs_log4net");
            DropTable("dbo.cc_TaskTimeSlots");
            DropTable("dbo.cc_Tasks_TimeSlots");
            DropTable("dbo.cc_Tasks");
            DropTable("dbo.cc_Sponsors");
            DropTable("dbo.cc_SpeakerRateEvent");
            DropTable("dbo.cc_PresenterBiographies");
            DropTable("dbo.cc_SpeakerRateSpeakers");
            DropTable("dbo.cc_Tags");
            DropTable("dbo.cc_SessionTags");
            DropTable("dbo.cc_TimeSlots");
            DropTable("dbo.cc_Rooms");
            DropTable("dbo.cc_ScheduledSessions");
            DropTable("dbo.cc_Sessions");
            DropTable("dbo.cc_SessionPresenters");
            DropTable("dbo.cc_SiteUsers");
            DropTable("dbo.cc_Presenters");
            DropTable("dbo.cc_IndividualContributors");
            DropTable("dbo.cc_CommunitySponsors");
            DropTable("dbo.cc_Events");
            DropTable("dbo.cc_Buildings");
            DropTable("dbo.cc_BannedTags");
        }
    }
}
